package com.szu.smart_illustrator.rest;

import jdk.nashorn.internal.ir.annotations.Ignore;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;


/**
 * 测试接口
 *
 * @author 冼铧城
 * @date 2023/12/18
 */
@RestController
@RequestMapping("test")
public class TestController {
    @GetMapping("/stream")
    @Ignore
    public StreamingResponseBody streamData() {
        // 假设你有一个能够产生大量数据的迭代器或流


        // 使用 StreamingResponseBody 返回数据
        return outputStream -> {
            for (int i = 0; i < 20; i++) {
                outputStream.write(22);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            outputStream.close();
        };
    }
}
